<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
  <meta charset="utf-8">
  <title>使用Pelican建立Blog</title>
  <meta name="author" content="Jason">



  <!-- http://t.co/dKP3o1e -->
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link href="./favicon.png" rel="icon">
  <link href="./theme/css/main.css" media="screen, projection"
        rel="stylesheet" type="text/css">
  <script src="./theme/js/modernizr-2.0.js"></script>
  <script src="./theme/js/ender.js"></script>
  <script src="./theme/js/octopress.js" type="text/javascript"></script>

  <link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic"
        rel="stylesheet" type="text/css">
  <link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic"
        rel="stylesheet" type="text/css">
</head>

<body>
  <header role="banner"><hgroup>
  <h1><a href="./">Jason Blog</a></h1>
</hgroup></header>
  <nav role="navigation"><ul class="subscription" data-subscription="rss">
</ul>



<ul class="main-navigation">
    <li >
    <a href="./category/c.html">C</a>
    </li>
    <li >
    <a href="./category/gdb.html">Gdb</a>
    </li>
    <li >
    <a href="./category/github.html">Github</a>
    </li>
    <li >
    <a href="./category/glib.html">Glib</a>
    </li>
    <li >
    <a href="./category/opencv.html">Opencv</a>
    </li>
    <li class="active">
    <a href="./category/pelican.html">Pelican</a>
    </li>
    <li >
    <a href="./category/protocol.html">Protocol</a>
    </li>
    <li >
    <a href="./category/python.html">Python</a>
    </li>
    <li >
    <a href="./category/regular.html">Regular</a>
    </li>
    <li >
    <a href="./category/sed.html">Sed</a>
    </li>
    <li >
    <a href="./category/stock.html">Stock</a>
    </li>
</ul></nav>
  <div id="main">
    <div id="content">
<div>
  <article class="hentry" role="article">
<header>
      <h1 class="entry-title">使用Pelican建立Blog</h1>
      <p class="meta"><time datetime="2014-09-26T19:28:04" pubdate>五 26 九月 2014</time></p>
</header>

  <div class="entry-content"><p>1.1 安裝Pelican</p>
<div class="highlight"><pre>pip install virtualenv
virtualenv pelican_env
<span class="nb">source </span>pelican_env/bin/activate
</pre></div>


<p>安裝pelican工具</p>
<div class="highlight"><pre>pip install pelican markdown ghp-import
</pre></div>


<p>1.2 建立 Github Page
* 在Github上創建一個倉庫，倉庫名是用戶名.github.io，注意這裡的用戶名是自己的用戶名</p>
<ul>
<li>建立好後，clone 到 local</li>
</ul>
<div class="highlight"><pre>git clone https://github.com/xxxx/xxx.github.io
<span class="nb">cd </span>xxx.github.io
</pre></div>


<p>2.1 建立 Pelican Blog
建立 source branch</p>
<div class="highlight"><pre>git checkout -b <span class="nb">source</span>
</pre></div>


<p>建立 Pelican</p>
<div class="highlight"><pre>pelican-quickstart
</pre></div>


<p>建立的過程中，會問你一些問題，你可以參考下面的回答。</p>
<div class="highlight"><pre>&gt; Where <span class="k">do </span>you want to create your new web site? <span class="o">[</span>.<span class="o">]</span> 
&gt; What will be the title of this web site? Buttermilch
&gt; Who will be the author of this web site? Tony Stark
&gt; What will be the default language of this web site? <span class="o">[</span>en<span class="o">]</span> 
&gt; Do you want to specify a URL prefix? e.g., http://example.com   <span class="o">(</span>Y/n<span class="o">)</span> n
&gt; Do you want to <span class="nb">enable </span>article pagination? <span class="o">(</span>Y/n<span class="o">)</span> 
&gt; How many articles per page <span class="k">do </span>you want? <span class="o">[</span>10<span class="o">]</span> 
&gt; Do you want to generate a Fabfile/Makefile ... and publishing? <span class="o">(</span>Y/n<span class="o">)</span> 
&gt; Do you want an auto-reload &amp; simpleHTTP ... and site development? <span class="o">(</span>Y/n<span class="o">)</span> 
&gt; Do you want to upload your website using FTP? <span class="o">(</span>y/N<span class="o">)</span> 
&gt; Do you want to upload your website using SSH? <span class="o">(</span>y/N<span class="o">)</span> 
&gt; Do you want to upload your website using Dropbox? <span class="o">(</span>y/N<span class="o">)</span> 
&gt; Do you want to upload your website using S3? <span class="o">(</span>y/N<span class="o">)</span> 
&gt; Do you want to upload your website using Rackspace Cloud Files? <span class="o">(</span>y/N<span class="o">)</span>
</pre></div>


<p>2.1.1 安裝 theme 跟 plugins</p>
<div class="highlight"><pre>git clone https://github.com/jakevdp/pelican-octopress-theme.git
git clone https://github.com/getpelican/pelican-plugins.git
</pre></div>


<p>將 pelicanconf.py 檔案裡的 THEME 跟 PLUGIN_PATH 修改成你放置 pelican-octopress-theme 跟 pelican-plugins 的路徑：</p>
<div class="highlight"><pre>import os ＃ 新增
<span class="nv">path</span> <span class="o">=</span> os.path.join<span class="o">(</span>os.environ.get<span class="o">(</span><span class="s1">&#39;HOME&#39;</span><span class="o">)</span>, <span class="s1">&#39;pelican&#39;</span><span class="o">)</span>
<span class="nv">THEME</span> <span class="o">=</span> <span class="s1">&#39;%s/pelican-octopress-theme&#39;</span> % path
<span class="nv">PLUGIN_PATH</span> <span class="o">=</span> <span class="s1">&#39;%s/pelican-plugins&#39;</span> % path
</pre></div>


<p>2.2 建立Markdown文章</p>
<div class="highlight"><pre>Title: 你好，世界！
Date: 2014-09-26 16:08
Category: Python
Tags: python
Author: Jason
Summary: 你好，世界！
你好，世界，世界，你好。
</pre></div>


<p>2.3 Local test
編寫好了之後，就可以在本地進行測試了。</p>
<div class="highlight"><pre>pelican content -s pelicanconf.py --ignore-cache
<span class="nb">cd </span>output
python -m SimpleHTTPServer 1111
</pre></div>


<p>2.4 提交更改</p>
<div class="highlight"><pre>git add .
git commit -m <span class="s2">&quot;initial commit&quot;</span>
</pre></div>


<p>2.5 發佈</p>
<div class="highlight"><pre>git branch gh-pages
ghp-import output
git checkout master
git merge gh-pages
git push --all
</pre></div>


<p>2.6 之後修改文章只需下面步驟即可</p>
<div class="highlight"><pre>git checkout <span class="nb">source</span>
新增修改文章
git add .
git commit -m <span class="s2">&quot;update&quot;</span>
ghp-import output
git checkout master
git merge gh-pages
git push --all
</pre></div></div>
    <footer>
<p class="meta">
  <span class="byline author vcard">
    Posted by <span class="fn">Jason</span>
  </span>
<time datetime="2014-09-26T19:28:04" pubdate>五 26 九月 2014</time>  <span class="categories">
    <a class="category" href="./tag/pelican.html">Pelican</a>
  </span>
</p><div class="sharing">
</div>    </footer>
  </article>

</div>
<aside class="sidebar">
  <section>
    <h1>Recent Posts</h1>
    <ul id="recent_posts">
      <li class="post">
          <a href="./glib-bian-yi-an-zhuang.html">Glib 編譯& 安裝</a>
      </li>
      <li class="post">
          <a href="./gdb-bian-yi-an-zhuang.html">GDB 編譯＆安裝</a>
      </li>
      <li class="post">
          <a href="./zhuan-spiuarti2cdu-you-shi-mo-qu-bie-ji-qi-ge-zi-de-te-dian.html">[轉] SPI,UART,I2C都有什麼區別，及其各自的特點</a>
      </li>
      <li class="post">
          <a href="./zhuan-ben-yi-bi-per-gu-jia-jing-zhi-bi-pbr-gu-dong-quan-yi-bao-chou-lu-roe.html">[轉] 本益比(PER)、股價淨值比(PBR)、股東權益報酬率(ROE)</a>
      </li>
      <li class="post">
          <a href="./search-struct-or-class-prototype.html">search struct or class prototype</a>
      </li>
    </ul>
  </section>
  <section>
      
    <h1>Categories</h1>
    <ul id="recent_posts">
        <li><a href="./category/c.html">C</a></li>
        <li><a href="./category/gdb.html">GDB</a></li>
        <li><a href="./category/github.html">github</a></li>
        <li><a href="./category/glib.html">Glib</a></li>
        <li><a href="./category/opencv.html">opencv</a></li>
        <li><a href="./category/pelican.html">Pelican</a></li>
        <li><a href="./category/protocol.html">protocol</a></li>
        <li><a href="./category/python.html">Python</a></li>
        <li><a href="./category/regular.html">regular</a></li>
        <li><a href="./category/sed.html">sed</a></li>
        <li><a href="./category/stock.html">stock</a></li>
    </ul>
  </section>
 

  <section>
  <h1>Tags</h1>
    <a href="./tag/glib.html">Glib</a>,    <a href="./tag/pelican.html">Pelican</a>,    <a href="./tag/c.html">C</a>,    <a href="./tag/github.html">github</a>,    <a href="./tag/sed.html">sed</a>,    <a href="./tag/python.html">python</a>,    <a href="./tag/protocl.html">Protocl</a>,    <a href="./tag/opencv.html">opencv</a>,    <a href="./tag/gdb.html">gdb</a>,    <a href="./tag/regular.html">regular</a>,    <a href="./tag/protocol.html">protocol</a>,    <a href="./tag/stock.html">stock</a>  </section>


    <section>
        <h1>Social</h1>
        <ul>
            <li><a href="#" target="_blank">You can add links in your config file</a></li>
            <li><a href="#" target="_blank">Another social link</a></li>
        </ul>
    </section>
    <section>
        <h1>Blogroll</h1>
        <ul>
            <li><a href="http://getpelican.com/" target="_blank">Pelican</a></li>
            <li><a href="http://python.org/" target="_blank">Python.org</a></li>
            <li><a href="http://jinja.pocoo.org/" target="_blank">Jinja2</a></li>
            <li><a href="#" target="_blank">You can modify those links in your config file</a></li>
        </ul>
    </section>

</aside>    </div>
  </div>
  <footer role="contentinfo"><p>
  Copyright &copy; 2013 - Jason -
  <span class="credit">Powered by <a href="http://getpelican.com">Pelican</a></span>
</p></footer>
</body>
</html>